package com.zking.controller.captcha;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by 刘庆文 on 2022-2022-8-9, project: SsmAndBootAndCloud.
 * <p>
 * Author: 刘庆文
 * Create Date: 2022-8-9
 * Project: me.liuqingwen.controller in project: SsmAndBootAndCloud
 * <p>
 * Notice: If you are using this class or file, check it and do some modification.
 */
@Controller
public class TestController {
    @RequestMapping
    public String index() {
        return "index";
    }
    
    @RequestMapping("/login")
    public String login(String Username, String password, HttpSession session) {
        // 必须判断是否经过了图形验证，防止恶意请求
        if (session.getAttribute("checked") == null) {
            // 没通过图形验证，直接返回自己的页面
            return "index";
        }
        // 删除这一次图形校验
        session.removeAttribute("checked");
        // 接下来验证用户名密码等，返回自己的页面
        // --------------------
        return "index";
    }
    
    // ==============================
    // 一些视图：用于测试
    @RequestMapping("/captcha/slider")
    public String slider() {
        return "captcha/slider";
    }
    
    @RequestMapping("/captcha/rotate")
    public String rotate() {
        return "captcha/rotate";
    }
    
    @RequestMapping("/captcha/concat")
    public String concat() {
        return "captcha/concat";
    }
    
    @RequestMapping("/captcha/word-click")
    public String wordClick() {
        return "captcha/word-click";
    }
}
